package com.sherlockHolmes.init.controller;

import com.sherlockHolmes.init.base.result.Ajax;
import com.sherlockHolmes.init.service.AggregateSearchService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/index")
public class AggregateSearch {
    @Resource
    private AggregateSearchService aggregateSearchService;
    /**
     * 首页聚合搜索
     */
    @GetMapping("/search")
    public Ajax search(@RequestParam("condition") String condition,@RequestParam("type")String type,@RequestParam("page")Integer page) {
        try{
           return Ajax.success(aggregateSearchService.search(condition,type,page));
        }catch (Exception e){
            return Ajax.fail(e);
        }
    }
}
